/* 
定义带getter和setter的属性
功能类似于defineProperty
*/

class RefImpl {
  constructor (value) {
    this._value = value
  }

  get value () {
    console.log('监视到读value')
    return this._value
  } 
  
  set value (newValue) {
    if (this._value!==newValue) {
      console.log('监视到写value')
      this._value = newValue
    }
  }
}

function ref(value) {
  return new RefImpl(value)
}

const countRef = ref(3)
console.log(countRef)
countRef.value = 4   // set
console.log(countRef.value) // get



